package com.faithbj.device.service.impl;

import javax.annotation.Resource;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.faithbj.device.dao.StockDao;
import com.faithbj.device.model.configuration.Pager;
import com.faithbj.device.model.entity.Stock;
import com.faithbj.device.service.StockService;

@Service("stockService")
@Transactional
public class StockServiceImpl implements StockService {
	
	@Resource
	private StockDao stockDao;

	@Override
	public Pager findByPager(Pager pager) {
		return stockDao.findByPager(pager);
	}

	@Override
	public Stock load(String id) {
		return stockDao.load(id);
	}

	@Override
	public Stock get(String id) {
		return stockDao.get(id);
	}

	@Override
	public void update(Stock persistent) {
		stockDao.update(persistent);
	}

	@Override
	public void save(Stock con) {
		stockDao.save(con);
	}

	@Override
	public void delete(String id) {
		stockDao.delete(id);
	}

	@Override
	public Pager findByPager(Pager pager, int isInStock) {
		DetachedCriteria criteria = DetachedCriteria.forClass(Stock.class);
		criteria.add(Restrictions.eq("isInStock", isInStock));
		return stockDao.findByPager(pager, criteria);
	}

}
